package com.booby.algorithm.utils;

import com.booby.algorithm.quick.QuickCheck;

import java.util.Random;

/**
 * 功能描述: 校验排序算法是否正确
 *
 * @author: lizt
 * @date: 2020/8/14 07:47
 **/

public class DataCheckUtil {
    public static final int ARRAY_LENGH = 10000;
    public static final int RANDOM_SEED = 10000;
    public static final int REPEAT_COUNT = 10;

    public static Integer[] generateDataSource(){
        Random random = new Random();
        Integer[] array = new Integer[ARRAY_LENGH];
        for (int i = 0; i < ARRAY_LENGH ; i++) {
            array[i] = random.nextInt(RANDOM_SEED);
        }
        return array;
    }


    public static Integer[] generateDataSourceScope(int min, int max){
        Random random = new Random();
        Integer[] array = new Integer[ARRAY_LENGH];
        for (int i = 0; i < ARRAY_LENGH ; i++) {
            array[i] = random.nextInt(max)%(max-min+1) + min;
        }
        return array;
    }




    private static void repeatCheck(){
        for (int i = 0; i < REPEAT_COUNT; i++) {
            check();
        }
    }

    private static void check(){
        // 选择排序校验
        // SelectionCheck.check();
        // 冒泡排序
        // BubbleCheck.check();
        // 插入排序
        //InsertionCheck.check();
        // 希尔排序
        //ShellCheck.check();
        // 归并排序
        //MergeCheck.check();
        // 快速排序
        QuickCheck.check();
        // 计数排序
        //CountingCheck.check();
        // 基数排序
        //RedixCheck.check();
    }



    public static void main(String[] args) {
        repeatCheck();
    }

}
